//
//(C) Copyright 2011 HongKong Airline.,Ltd. 
//
/**
 * accountAction
 * 项目名称:代购系统
 * @author Mengxiangliang
 * 功能描述:
 * 历史版本:2013-01-04 v1.0.0 Mengxiangliang  创建:
 * @version [V1] 
 */
package com.gamutsoft.amb.account.action;

import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

import com.gamutsoft.amb.account.model.Account;
import com.gamutsoft.amb.account.service.IAccountService;
import com.gamutsoft.amb.base.action.BaseAction;
import com.gamutsoft.amb.common.bean.QueryExample;
import com.gamutsoft.amb.common.exception.BusinessException;
import com.gamutsoft.amb.common.util.ConditionUtil;
import com.gamutsoft.amb.common.util.PageUtil;


@SuppressWarnings({"serial","rawtypes"})
public class AccountAction extends BaseAction {
	
	private Account account;
	
	private List<Map> accountList;
	
	
	private IAccountService accountService;
    /**
     * 跳转到我的账户页面
     * @return
     * @throws BusinessException
     * @throws Exception
     */
	public String gotoMyAccount()throws BusinessException, Exception{
		//获取我的账户
		Long userId=super.getSystemUser().getId();
		account=accountService.searchAccountByUserId(userId);
		return"goto_account";
	}
  /**
   * 获取我的账户信息
   */
	public void ajaxForMyAccount()throws BusinessException, Exception{
		PrintWriter out;
		out = this.getResponse().getWriter();
		String result="";
		try{
			Long userId=super.getSystemUser().getId();
			account=accountService.searchAccountByUserId(userId);
			if(account!=null){
			result="{'balance':'"+account.getBalance()+"','integral':'"+account.getIntegral()+"','status':'"+account.getStatus()+"'}";
			}
		}catch(Exception e){
			log.error(e,e);
		}
		out.print(result);
	}
	/**
	 * @return the account
	 */
	public Account getAccount() {
		return account;
	}

	/**
	 * @param account the account to set
	 */
	public void setAccount(Account account) {
		this.account = account;
	}

	/**
	 * @return the accountList
	 */
	public List<Map> getAccountList() {
		return accountList;
	}

	/**
	 * @param accountList the accountList to set
	 */
	public void setAccountList(List<Map> accountList) {
		this.accountList = accountList;
	}

	/**
	 * @param accountService the accountService to set
	 */
	public void setAccountService(IAccountService accountService) {
		this.accountService = accountService;
	}
}
